# -*- coding:utf-8 -*-

'''
PROJECT_NAME : auth_demo
file    : middlerware
author  : 1032162439@qq.com
date    : 2022-09-08 13:48
IDE     : PyCharm
'''
from django.utils.deprecation import MiddlewareMixin
from django.conf import settings
from django.shortcuts import reverse, redirect


class MyAuthMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.path not in settings.WHITE_LIST:
            if not request.COOKIES.get('user'):
                return redirect(reverse('myauth:login'))
            return
        return
